﻿#ifndef TABBARWIDGET_H
#define TABBARWIDGET_H

#include <QWidget>
#include <QList>
#include <tabbarbutton.h>
#include <QAuthenticator>
#include "customwebview.h"
#include "customwebpage.h"
#include "notifymanager.h"
#include "historymanager.h"
#include "global.h"

class CustomWebView;
namespace Ui {
class TabBarWidget;
}

class TabBarWidget : public QWidget
{
    Q_OBJECT

public:
    explicit TabBarWidget(QWidget *parent = nullptr);
    ~TabBarWidget();

    CustomWebView *createTab();

    CustomWebView *createBackgroundTab();

    void removeTab(TabBarButton *tab_ptr);

    void clickTab(TabBarButton *tab_ptr);

    void setCurrentWebView(CustomWebView *view);

    void addTab(CustomWebView *view);

    TabBarButton * currentTab = nullptr;

    // 更改标签页图片
    void setTabIcon();

    void setProfile(QWebEngineProfile *_profile){this->profile = _profile;}
    QWebEngineProfile * getProfile(){return this->profile;}

private slots:
    void on_add_tab_btn_clicked();

signals:
    void changeView(TabBarButton * tab_ptr);
    void removeView(TabBarButton *tab_ptr);
    void changeUrl(QString url);
    void linkHover(const QString &url);

private:
    Ui::TabBarWidget *ui;
    QList<QWidget*> *tab_btns;
    QWebEngineProfile *profile;
};

#endif // TABBARWIDGET_H
